//***********************************************************************
//	File:		Pwner.cpp
//	Author:		
//	Course:		SGP 1405
//	Purpose:	
//***********************************************************************
//***********************************************************************
//	Purposfully left blank for all comments regarding this file 
//	
//	
//	
//***********************************************************************



#include "Pwner.h"

Pwner::Pwner(float posX, float posY)
{
	SetAcceleration({ 0 , 0 }); 
	SetAttackCDL(.35f); 
	SetAttackRange(500); 
	SetConfuseCDL(4); 
	SetConfuseTimer(0); 
	SetDynamicFrictionCoefficient(.4f); 
	SetHealth(100); 
	//SetImage(); 
	SetKnockbackCDL(4); 
	SetKnockBackTimer(0);
	SetMass(120); 
	SetMaxHealth(100); 
	SetMaxShield(300); 
	SetMaxSpeed(50); 
	SetPassable(false);
	SetPosition(SGD::Point{ posX, posY }); 
	SetProjectileType(ENT_BULLET); 
	SetRootCDL(4); 
	SetRootTimer(0); 
	SetRotation(0); 
	SetShield(300); 
	SetShieldRechargeDelay(3); 
	SetShieldRechargeRate(20);
	SetSize(SGD::Size{ 64, 64 }); 
	SetSpeed(0); 
	SetStaticFrictionCoefficient(.7f); 
	//SetTakeDamage() particle emitter
	SetTarget(nullptr); 
	SetValue(ENT_PWNER);
	SetVelocity(SGD::Vector{ 0, -1 }); 
	m_hImage = SGD::GraphicsManager::GetInstance()->LoadTexture(
		L"reources/graphics/Pwner.png");

}

//Interface
void Pwner::Update(float dt)
{

	if (m_bMove == true)
	{

		if (pTarget)
		{
			SGD::Vector vec = pTarget->GetPosition() - GetPosition();
			vec.Normalize();
			vec *= 75.0f;

			SetPosition(GetPosition() + vec * dt);
		}


		if (pTarget->GetPosition().x - this->GetPosition().x <= 300 && pTarget->GetPosition().y - this->GetPosition().y <= 300)
			Attack(dt);

		if (m_fAttackCDL <= 0)
			m_fAttackCDL -= dt;

	}


	//Last line of function
	Entity::Update(dt); 
}

void Pwner::Render()
{
	SGD::GraphicsManager::GetInstance()->DrawTexture(m_hImage, GetPosition(), 0.0, SGD::Vector(0, 0), SGD::Color(), SGD::Size(64, 64));
}

void Pwner::HandleCollision(const IEntity* pOther)
{
	Entity::HandleCollision(pOther);
}

void Pwner::HandleEvent()
{

}

SGD::Rectangle Pwner::GetRect() const
{
	return SGD::Rectangle{}; 
}

void Pwner::ModifyHealth(float hpAmount)
{
	m_fTotalHP -= hpAmount;
}

void Pwner::ApplyFriction(float dt)
{

}

//Enemy Interface
void Pwner::Attack(float dt)
{
	if (pTarget->GetPosition().x - this->GetPosition().x <= 300 && pTarget->GetPosition().y - this->GetPosition().y <= 300)
	{

		if (m_fAttackCDL <= 0)
		{

			GetDamage();
			m_fAttackCDL = 10;

		}

	}
}

void Pwner::Move(void)
{

}


//Pwner specific 
void Pwner::Hide()
{

}
